Skip to content

Fix/rpc retry - #353

Merged
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
Opulencechuks:fix/rpc-retry
Aug 20, 2026
Merged

Fix/rpc retry#353
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
Opulencechuks:fix/rpc-retry

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

Closes #325

Description

This PR resolves the issue where transient RPC errors (such as timeouts, rate limits, and temporary node unavailability) were propagating immediately and causing avoidable failures in access checks. It introduces a resilient, configurable exponential backoff retry mechanism in ContractClient to ensure transient failures are seamlessly retried without caller intervention.

Linked Issue

Closes #

Type of Change

  • 🐛 Bug fix
  • ✨ New feature / enhancement
  • 📝 Documentation update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made

  • packages/integration-client/src/contracts/contractHelpers.ts: Introduced withRetry(fn, options) utility which executes functions with exponential backoff and jitter. Added isRetryableError(error) to determine which errors are safe to retry (e.g., RPC rate limits like -32005, HTTP 429, 500-504, connection resets, and timeouts).
  • packages/integration-client/src/config/sdkConfig.ts: Added sdkConfig.rpcRetry setting to make the max attempts, base delay, and max delay configurable globally.
  • packages/integration-client/src/contracts/contractClient.ts: Wrapped the RPC call() execution with the new withRetry utility utilizing the sdkConfig.
  • packages/integration-client/test/contracts.test.ts: Implemented unit tests simulating both transient JSON-RPC failures followed by success (verifying the retry works), as well as permanent JSON-RPC failures (verifying that they fail immediately without draining retry attempts).
  • packages/integration-client/src/index.ts: Exported the new helper and config modules for downstream usage.

Test Evidence

Automated unit tests have been added and successfully run against the new retry logic. The tests verify:

  1. ContractClient - retry on transient JSON-RPC error: Successfully intercepts a JSON-RPC -32005 (rate limit) error returned with an HTTP 200 OK, applies the backoff delay, and successfully retrieves the result on the second attempt.
  2. ContractClient - no retry on permanent JSON-RPC error: Successfully intercepts a JSON-RPC 3 (execution reverted) error and immediately fails without attempting to retry.

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes with no errors
  • pnpm lint passes (or issues are pre-existing and documented)
  • pnpm test passes (all existing tests still pass)
  • The dashboard starts and renders correctly (if UI or API code changed)
  • The Discord bot still starts and responds to commands (if bot code changed)
  • Docs site renders correctly (if docs changed): pnpm dev:docs
  • No secrets, tokens, or API keys are included in this PR
  • Environment variable changes are reflected in .env.example
  • I have updated documentation if new behaviour was introduced

Screenshots / Recordings

N/A (SDK / Backend utility change).

Additional Notes

This specifically targets JSON-RPC payload errors (like rate limits returned with a 200 OK status) that standard HTTP transport-layer retries miss.

@Lakes41
Lakes41 merged commit 5ac3bc0 into Adamantine-guild:main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add retry-with-backoff wrapper to contractClient RPC calls

2 participants